package com.garbagecan.cachestudy.ehcache;

import java.net.URL;

import net.sf.ehcache.CacheManager;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class CacheManagerExample {

	private static Log log = LogFactory.getLog(CacheManagerExample.class);

	public static void main(String[] args) {
		testSingleton();
		
		testLoadConfig();
	}

	public static void testSingleton () {
		CacheManager cacheManager1 = CacheManager.create();
		CacheManager cacheManager2 = CacheManager.getInstance();
		
		log.info(cacheManager1);
		log.info(cacheManager2);
		log.info(cacheManager1.equals(cacheManager2));
		
		cacheManager1.shutdown();
		cacheManager2.shutdown();
	}

	public static void testLoadConfig() {
		URL url = CacheManagerExample.class.getResource("ehcache.xml");
		CacheManager cacheManager = new CacheManager(url);
		log.info(cacheManager);

		cacheManager.shutdown();
	}
}
